#ifndef FK_SYSTEM_OBJECT_H
#define FK_SYSTEM_OBJECT_H

#include <QObject>
#include "FKFactory.cpp"

#include "fkobjects_global.h"

class QDataStream;
template <class D> class FKFactory;

class FKOBJECTSSHARED_EXPORT FKSystemObject : public QObject{
    Q_OBJECT
public:
    FKSystemObject();
    ~FKSystemObject();
    virtual void packObject(QDataStream &stream);
    static FKSystemObject* loadObject(QDataStream &stream);
    template <class D> static void addClass();
protected:
    virtual void pack(QDataStream &stream);
    virtual bool load(QDataStream &stream);
    static FKSystemObject* createObject(QString className);
    static FKSystemObject* createObject(QString className, qint32 id);
private:
    static FKFactory<FKSystemObject>* _factory;
};

template <class D>
void FKSystemObject::addClass(){
    _factory->addClass<D>();
}

#endif // FKSYSTEMOBJECT_H
